<style lang="less" scoped>
  .f-mt10 {
    margin-top: 10px;
  }

  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }

  .f-mb10 {
    margin-bottom: 20px;
  }

  .avatar-uploader .el-upload:hover {
    border-color: #20a0ff;
  }

  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }

  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .f-w70 {
    width: 70%;
  }

  .f-w125 {
    width: 125%;
  }

  .f-w100 {
    width: 100%;
  }

  .my {
    margin-left: -60px;
  }

  .f-w120 {
    width: 120%;
  }

  .width70 {
    width: 70%;
  }

  .el-dialog {
    flex: 1;
    .isreceipt {
      display: none;
    }
    .receipt {
      display: inline-block;
    }
  }

  .backcolor {
    background-color: aqua
  }

  .f-w80 {
    position: absolute;
    margin-top: -6px;
    width: 80px;
  }

</style>

<template>
  <section>
    <!--工具条-->
    <!--工具条-->
    <search-bar more-display>
      <el-row>
        <el-col :span="8">
          <el-form-item label="发票类型">
            <el-select  v-model="searchCondition.EQ_taxsheetType"
                       placeholder="请选择">
              <el-option
                v-for="item in $store.getters.TAXSHEET_TYPE"
                :key="item.dictVal"
                :label="item.cnDictValname"
                :value="item.dictVal">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="发票抬头">
            <el-input
                      v-model="searchCondition.LIKE_taxsheetTitle" placeholder="请输入发票抬头"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收件人">
            <el-input
                      v-model="searchCondition.LIKE_consigneeName" placeholder="请输入收件人"></el-input>

          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="手机号">
            <el-input
                      v-model="searchCondition.LIKE_phone" placeholder="请输入手机号"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收件地址">
            <el-input
                      v-model="searchCondition.LIKE_collectAddress" placeholder="请输入收件地址"></el-input>
          </el-form-item>
        </el-col>

      </el-row>

    </search-bar>
    <!-- 操作 -->
    <el-col :span="24" style="margin-bottom: 10px">
      <el-button type="primary" @click="handleAdd">新增</el-button>
      <label style="margin-left: 20px"><b>企业专用发票</b>支持直接上传照片啦~
        <el-upload
          class="upload-demo"
          style="display: inline-block"
          :file-list="fileList"
          :on-success="handleOnUploadSuccess"
          :before-upload="beforeAvatarUpload"
          :show-file-list="false"
          :on-error="handleAvatarError"
          :action="'/api/v2.0/admin/taxsheet_title_en_tax' ">
          <el-button  type="primary">点击上传</el-button>
        </el-upload>
      </label>
      <el-button type="primary" @click="myReset" style="float: right">重置</el-button>
      <el-button type="primary" @click="searchInvoiceManage" style="float: right;margin-right: 10px">查询</el-button>
    </el-col>

    <!--列表-->
    <el-table :data="tableData" highlight-current-row border @sort-change="sortChange"
              @selection-change="selsChange" v-loading="listLoading" style="width: 100%;">
      <el-table-column
        label="默认"
        width="80">
        <template slot-scope="scope">
          <label v-if="scope.row.isDefault === 111002001">
            <i class="el-icon-check"></i>
          </label>
          <label v-if="scope.row.isDefault === 111002002">
          </label>
        </template>
      </el-table-column>
      <el-table-column prop="typeName" label="发票类型" width="280" >
      </el-table-column>
      <el-table-column prop="taxsheetTitle" label="发票抬头" width="250" >
      </el-table-column>
      <el-table-column prop="consigneeName" label="收件人" width="170" >
      </el-table-column>
      <el-table-column prop="phone" label="手机号" width="150" >
      </el-table-column>
      <el-table-column prop="telphone" label="固定电话" width="150" >
      </el-table-column>
      <el-table-column prop="collectAddress" label="收件人地址" width="250" >
      </el-table-column>
      <el-table-column label="操作" width="300">
        <template slot-scope="scope">
          <el-button  type="primary" v-if="scope.row.taxsheetType !==102013004"
                     @click="getEditBYId(scope.$index, scope.row)">编辑
          </el-button>
          <el-button type="danger"
                     @click="doDeleteTaxsheetTitle(scope.row)">删除
          </el-button>
          <el-button type="primary"  v-if="scope.row.taxsheetType ===102013004"
                     @click="showEnValueAddedTax(scope.row)">查看图片
          </el-button>
          <el-button type="primary"  v-if="scope.row.isDefault ===111002002"
                     @click="modifyDefault(scope.$index, scope.row)">设为默认
          </el-button>
        </template>
      </el-table-column>

    </el-table>
    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-pagination
        :current-page="currentPage"
        :page-size="pageSize"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total,sizes,prev, pager, next, jumper"
        :total="total" style="float: right">
      </el-pagination>
    </el-col>
    <el-dialog :title="dialogTitle"  :visible.sync="invoiceManageVisible" :close-on-click-modal="false">
      <el-form :model="invoiceManage" :rules="rule" label-width="120px" ref="invoiceManage">
        <el-row class="f-mt10 f-mb10">
          <el-form-item label="发票类型" prop="taxsheetType">
            <el-radio-group v-model="invoiceManage.taxsheetType"
                            @change="changeData(invoiceManage.taxsheetType)">
              <el-radio :label="102013001" style="float: left">个人普通发票

              </el-radio>
              <el-radio :label="102013002" style="float: left">单位普通发票

              </el-radio>
              <el-radio :label="102013003" style="float: left">单位增值税发票

              </el-radio>
            </el-radio-group>
            <br>
            <div class="f-mt10 f-mb10"
                 v-if="invoiceManage.taxsheetType == 102013001 || invoiceManage.taxsheetType == 102013002 ">
              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="发票抬头" prop="taxsheetTitle">
                    <el-input class="width70" v-model="invoiceManage.taxsheetTitle" placeholder="请输入发票抬头"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="收件人" prop="consigneeName">
                    <el-input class="width70" v-model="invoiceManage.consigneeName" placeholder="请输入收件人名称"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="手机号" prop="phone" :rules="[
            {required: true, message: '请输入手机号', trigger: 'change'},
            {min:11,max:11, message: '长度在11个字符', trigger: 'change'}
          ]">
                    <el-input class="width70" type="number" v-model="invoiceManage.phone"
                              placeholder="请输入手机号"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="固定电话">
                    <el-input class="width70" type="number" v-model="invoiceManage.telphone"
                              placeholder="请输入固定电话"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="通信地址" prop="myAddress">
                    <address-select v-model="invoiceManage.myAddress"
                                    placeholder="请选择地址"
                                    class="width70">

                    </address-select>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="详细地址" prop="street">
                    <el-input class="width70" v-model="invoiceManage.street"
                              placeholder="请输入详细地址"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item class="width70" prop="isDefault">
                    <el-checkbox v-model="invoiceManage.isDefault" :true-label="102013001" :false-label="102013002">
                      设为默认
                    </el-checkbox>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
            <div v-if="invoiceManage.taxsheetType == 102013003">
              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="发票抬头" prop="invoiceTitle">
                    <el-input class="width70" v-model="invoiceManage.taxsheetTitle" placeholder="请输入发票抬头"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="纳税人识别号" prop="taxpayersRegistrationNumber">
                    <el-input class="width70" v-model="invoiceManage.taxpayersRegistrationNumber"
                              placeholder="请输入纳税人识别号"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="开户银行" prop="openingBank">
                    <el-input class="width70" v-model="invoiceManage.openingBank" placeholder="请输入开户银行"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="开户银行账号" prop="bankAccount" :rules="[
            {required: true, message: '请输入开户银行账号', trigger: 'change'},
            {min:16,max:19, message: '长度在16-19个字符', trigger: 'change'}
          ]">
                    <el-input class="width70" type="number" v-model="invoiceManage.bankAccount"
                              placeholder="请输入开户银行账号"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="注册地" prop="registerLocalHost">
                    <el-input class="width70" v-model="invoiceManage.registerLocalHost"
                              placeholder="请输入登记注册地"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="公司电话" prop="companyTelphone" :rules="[
            {required: true, message: '请输入公司电话', trigger: 'change'},
            {min:7,max:12, message: '长度在7-12个字符', trigger: 'change'}
          ]">
                    <el-input class="width70" type="number" v-model="invoiceManage.companyTelphone"
                              placeholder="请输入公司电话"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="12">
                  <el-form-item label="上传营业执照" prop="businessLicenseUrl">
                    <el-upload
                      class="avatar-uploader"
                      action="/api/v2.0/admin/taxsheet_title_up_load"
                      :show-file-list="false"
                      :on-error="handleAvatarError"
                      :on-remove="handleRemove"
                      :on-success="handlePreview"
                      :before-upload="beforeAvatarUpload">
                      <img width="75%" v-if="oldHeadUrl && invoiceManage.businessLicenseUrl"
                           :src="decodeURI(invoiceManage.httpHead+invoiceManage.businessLicenseUrl)"
                           class="avatar">
                      <img v-else-if="!oldHeadUrl && tempCurrentHeadUrl" :src="tempCurrentHeadUrl" class="avatar">
                      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="纳税人证明" prop="taxpayerProveUrl">
                    <el-upload
                      class="avatar-uploader"
                      action="/api/v2.0/admin/taxsheet_title_up_load1"
                      :show-file-list="false"
                      :on-error="handleAvatarError"
                      :on-remove="handleRemove"
                      :on-success="handlePreview1"
                      :before-upload="beforeAvatarUpload">
                      <img width="75%" v-if="oldHeadUrl1 && invoiceManage.taxpayerProveUrl"
                           :src="decodeURI(invoiceManage.httpHead+invoiceManage.taxpayerProveUrl)"
                           class="avatar">
                      <img v-else-if="!oldHeadUrl1 && tempCurrentHeadUrl1" :src="tempCurrentHeadUrl1" class="avatar">
                      <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                    </el-upload>
                  </el-form-item>
                </el-col>

              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="收件人" prop="consigneeName">
                    <el-input class="width70" v-model="invoiceManage.consigneeName" placeholder="请输入收件人名称"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="手机号" prop="phone" :rules="[
            {required: true, message: '请输入手机号', trigger: 'change'},
            {min:11,max:11, message: '长度在11个字符', trigger: 'change'}
          ]">
                    <el-input class="width70" type="number" v-model="invoiceManage.phone"
                              placeholder="请输入手机号"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="固定电话">
                    <el-input class="width70" type="number" v-model="invoiceManage.telphone"
                              placeholder="请输入固定电话"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="通信地址" class="width70" prop="myAddress">
                    <address-select v-model="invoiceManage.myAddress"
                                    placeholder="请选择地址"
                                    class="width70">

                    </address-select>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item label="详细地址" prop="street">
                    <el-input class="width70" v-model="invoiceManage.street"
                              placeholder="请输入详细地址"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row class="f-mt10 f-mb10">
                <el-col :span="24">
                  <el-form-item class="width70" prop="isDefault">
                    <el-checkbox v-model="invoiceManage.isDefault" :true-label="111002001" :false-label="111002002">
                      设为默认
                    </el-checkbox>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>

          </el-form-item>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click.native="invoiceManageVisible = false">取消</el-button>
        <el-button type="primary" @click.native="handleSubmit" :loading="submitLoading">提交</el-button>
      </div>
    </el-dialog>

    <!--优惠线路 折扣 信息新增&&编辑Dialog-->
    <el-dialog title="企业增值税专用发票" :visible.sync="enterpriseDialog" >
      <img width="90%" v-bind:src="enterpriseValueAddedTaxUrl">
    </el-dialog>

  </section>
</template>
<script>
import {
  searchInvoiceManage,
  saveInvoiceManage,
  getInvoiceManage,
  modifyIsDefault,
  deleteTaxsheetTitle
} from '../../api/meb-user/TaxsheetTitle.js';
import {objToFilter, resetObjNull} from '../../lib/util';
export default {
  data () {
    return {
      enterpriseDialog: false,
      enterpriseValueAddedTaxUrl: '',
      fileList: [],
      oldHeadUrl1: true,
      oldHeadUrl: true,
      tempCurrentHeadUrl: '',
      tempCurrentHeadUrl1: '',
      searchCondition: {
        EQ_taxsheetType: null,
        LIKE_taxsheetTitle: null,
        LIKE_phone: null,
        LIKE_collectAddress: null,
        LIKE_consigneeName: null
      },
      condition: {
        name: '',
        number: ''
      },
      dialogTitle: '新增',

      sels: [],
      tableData: [],
      total: 0,
      currentPage: 1,
      pageSize: 10,
      sortProp: null,
      sortOrder: 'ascending',
      listLoading: false,

      sels1: [],
      total1: 0,
      currentPage1: 1,
      pageSize1: 15,
      sortProp1: null,
      sortOrder1: 'ascending',
      listLoading1: false,
      invoiceManageVisible: false,
      submitLoading: false,

      // v发票表单数据
      invoiceManage: {
        'id': null,
        'httpHead': null,
        'myAddress': [],
        'taxsheetType': null,
        'taxsheetTitle': null,
        'consigneeId': null,
        'consigneeName': null,
        'isActiveBilling': null,
        'phone': null,
        'telphone': null,
        'provinceId': null,
        'province': null,
        'city': null,
        'cityId': null,
        'county': null,
        'countyId': null,
        'town': null,
        'townId': null,
        'street': null,
        'isDefault': null,
        'taxpayersRegistrationNumber': null,
        'openingBank': null,
        'bankAccount': null,
        'registerLocalHost': null,
        'companyTelphone': null,
        'businessLicenseUrl': null,
        'taxpayerProveUrl': null
      },

      // 验证规则
      rule: {
        taxsheetTitle: [
          {required: true, message: '请输入发票抬头', trigger: 'blur'},
          {min: 2, max: 60, message: '长度在2 到 60 个字符', trigger: 'blur'}
        ],
        consigneeName: [
          {required: true, message: '请输入收件人名称', trigger: 'blur'},
          {min: 2, max: 60, message: '长度在2 到 60 个字符', trigger: 'blur'}
        ],
        taxpayersRegistrationNumber: [
          {required: true, message: '请输入纳税人识别号', trigger: 'blur'},
          {min: 15, max: 20, message: '长度在15到 20 个字符', trigger: 'blur'}
        ],
        businessLicenseUrl: [
          {required: true, message: '请上传营业执照图片', trigger: 'blur'}
        ],
        taxpayerProveUrl: [
          {required: true, message: '请上传纳税人证明图片', trigger: 'blur'}
        ],
        registerLocalHost: [
          {required: true, message: '请输入登记注册地', trigger: 'blur'},
          {min: 2, max: 60, message: '长度在2到 60 个字符', trigger: 'blur'}
        ],

        openingBank: [
          {required: true, message: '请输入开户银行', trigger: 'blur'},
          {min: 4, max: 50, message: '长度在4到 50 个字符', trigger: 'blur'}
        ],
        myAddress: [
          {type: 'array', required: true, message: '请选择地址', trigger: 'blur'}
        ],
        street: [
          {required: true, message: '请输入详细地址', trigger: 'blur'},
          {min: 2, max: 60, message: '长度在2 到 60 个字符', trigger: 'blur'}
        ]

      }

    };
  },
  methods: {
    showEnValueAddedTax (row) {
      this.enterpriseValueAddedTaxUrl = row.enterpriseValueAddedTaxUrl;
      this.enterpriseDialog = true;
    },
    doDeleteTaxsheetTitle (row) {
      this.$confirm('确认 删除 吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteTaxsheetTitle(row.id).then((res) => {
          if (res.data.successFlg) {
            this.getTableData();
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    handleOnUploadSuccess (response) {
      this.fileList = [];
      if (response.successFlg) {
        this.getTableData();
        this.$message('企业专用发票上传成功.');
      } else {
        this.$message.error(response.errorMsg);
      }
    },
    modifyDefault (index, row) {
      this.$confirm('确认将地址设为默认吗?', '提示', {
        type: 'warning'
      }).then(() => {
        this.listLoading = true;
        let idDefault = 111002001;
        modifyIsDefault(row.id, idDefault).then((res) => {
          this.listLoading = false;
          this.$message({
            message: '设置默认成功！',
            type: 'success'
          });
          this.getTableData();
        });
      }).catch(() => {
      });
    },
    // 图片上传限制
    beforeAvatarUpload (file) {
      let isJPG = false;
      if (file.type) {
        const fileTypes = 'image/jpeg;image/png;image/bmp;image/tiff;image/wmf';
        isJPG = fileTypes.indexOf(file.type) !== -1;
      }
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG/PNG/BMP/TIFF/WMF 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },
    handleAvatarError () {
      this.$message.error('上传图片失败!');
    },
    handleRemove (file, fileList) {
      console.log(file, fileList);
    },
    // 营业执照图片地址赋值
    handlePreview (res, file) {
      this.oldHeadUrl = false;
      this.invoiceManage.businessLicenseUrl = file.response.obj;
      this.tempCurrentHeadUrl = URL.createObjectURL(file.raw);// 临时
    },
    handlePreview1 (res, file) {
      this.oldHeadUrl1 = false;
      this.invoiceManage.taxpayerProveUrl = file.response.obj;
      this.tempCurrentHeadUrl1 = URL.createObjectURL(file.raw);// 临时
    },
    // 打开编辑界面
    getEditBYId (index, row) {
      this.resetForm();
      this.oldHeadUrl1 = false;
      this.oldHeadUrl = false;
      this.tempCurrentHeadUrl = '';
      this.tempCurrentHeadUrl1 = '';
      getInvoiceManage(row.id).then((res) => {
        if (res.data.successFlg) {
          this.oldHeadUrl = true;
          this.oldHeadUrl1 = true;
          this.invoiceManage = res.data.obj;
          this.invoiceManage.myAddress = [res.data.obj.provinceId, res.data.obj.cityId, res.data.obj.countyId, res.data.obj.townId];
        }
      });
      this.dialogTitle = '修改';
      this.invoiceManageVisible = true;
    },
    addressValue (value) {
      if (value) {
        return value;
      } else {
        return null;
      }
    },

    // 新增发票数据提交
    handleSubmit () {
      // 表单验证
      this.$refs['invoiceManage'].validate((valid) => {
        if (valid) {
          this.invoiceManage.provinceId = this.addressValue(this.invoiceManage.myAddress[0]);
          this.invoiceManage.cityId = this.addressValue(this.invoiceManage.myAddress[1]);
          this.invoiceManage.countyId = this.addressValue(this.invoiceManage.myAddress[2]);
          this.invoiceManage.townId = this.addressValue(this.invoiceManage.myAddress[3]);
          this.submitLoading = true;
          saveInvoiceManage(this.invoiceManage).then((res) => {
            this.submitLoading = false;
            if (res.data.successFlg === true) {
              this.invoiceManageVisible = false;
              this.$message.success('保存/修改成功！');
              this.searchInvoiceManage();
            } else {
              this.$message.error(res.data.errorMsg);
            }
          }).catch(function (error) {
            console.log(error);
          });
        } else {
          return false;
        }
      });
    },
    handleAdd () {
      this.invoiceManage.businessLicenseUrl = '';
      this.invoiceManage.taxpayerProveUrl = '';
      this.oldHeadUrl1 = false;
      this.oldHeadUrl = false;
      this.tempCurrentHeadUrl = '';
      this.tempCurrentHeadUrl1 = '';
      this.dialogTitle = '新增';
      this.resetForm();
      this.invoiceManage.taxsheetType = 102013001;
      this.invoiceManageVisible = true;
    },
    // 重置表单
    resetForm () {
      if (this.$refs.invoiceManage) {
        this.$refs.invoiceManage.resetFields();
      }
      // 当先点击修改，再点击新增，会出现值没有清空,修复处理
      for (let p in this.invoiceManage) {
        if (this.invoiceManage[p] instanceof Array) {
          this.invoiceManage[p] = [];
        } else {
          this.invoiceManage[p] = null;
        }
      }
    },

    //  搜索 栏重置
    myReset () {
      resetObjNull(this.searchCondition);
    },
    loadingLists (filter) {
      this.listLoading = true;
      searchInvoiceManage({
        filters: filter,
        size: this.pageSize,
        page: this.currentPage,
        sorts: (this.sortProp === null ? '' : (this.sortOrder === 'ascending' ? '-' : '+') + this.sortProp)
      }).then(res => {
        if (res.data.successFlg) {
          this.tableData = res.data.detailModelList;
          this.currentPage = res.data.currPage;
          this.total = res.data.totalCount;
          this.pageSize = res.data.pageSize;
          this.listLoading = false;
        }
      });
    },
    //      //  搜索栏搜索
    searchInvoiceManage () {
      this.loadingLists(objToFilter(this.searchCondition));
    },
    // 多选操作
    selsChange (sels) {
      this.sels = sels;
    },
    // 排序操作
    sortChange (o) {
      this.sortProp = o.prop;
      this.sortOrder = o.order;
      this.getTableData();
    },
    // 每页几条操作
    handleSizeChange (val) {
      this.pageSize = val;
      this.getTableData();
    },
    // 第几页操作
    handleCurrentChange (val) {
      this.currentPage = val;
      this.getTableData();
    },

    // 获取表格数据
    getTableData () {
      this.listLoading = true;
      searchInvoiceManage({
        filters: '',
        sorts: '',
        page: this.currentPage,
        size: this.pageSize
      }).then((res) => {
        if (res.data.successFlg === true) {
          this.tableData = res.data.detailModelList;
          this.currentPage = res.data.currPage;
          this.total = res.data.totalCount;
          this.pageSize = res.data.pageSize;
          this.listLoading = false;
        } else {
          this.$message.error(res.data.errorMsg);
        }
      });
    }
  },
  // 初始化数据
  mounted () {
    this.getTableData();
    this.$store.commit('initDict');
  }
}
;
</script>
